package cn.virens.web.components.open.oauth.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import me.zhyd.oauth.config.AuthConfig;
import me.zhyd.oauth.config.AuthConfig.AuthConfigBuilder;
import me.zhyd.oauth.request.AuthGiteeRequest;
import me.zhyd.oauth.request.AuthRequest;

@Component
public class GiteeAuthConfig extends AbstractAuthConfig {
	@Value("${oauth.gitee.type}")
	private String type;

	@Value("${oauth.gitee.client_id}")
	private String clientId;

	@Value("${oauth.gitee.client_secret}")
	private String clientSecret;

	@Value("${oauth.gitee.redirect_uri}")
	private String redirectUri;

	@Override
	protected String getType() {
		return type;
	}

	@Override
	protected AuthRequest getRequest() {
		AuthConfigBuilder builder = AuthConfig.builder();
		builder.clientSecret(clientSecret);
		builder.redirectUri(redirectUri);
		builder.clientId(clientId);

		return new AuthGiteeRequest(builder.build(), mAuthStateCache);
	}
}
